<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		#box{
			width: 200px;
			height: 200px;
			background: red url() 0 0 no-repeat;
		}
	</style>
	<script>
		
		window.onload=function(){
			box = document.getElementById('box')

			width = 200
			is_zan = true;
			function run() {

				if(width>400){
					is_zan = false;
				}else if(width<200){
					is_zan = true;
				}

				if(is_zan){
					width += 2;
				}else{
					width -= 2;
				}
				
				box.style.width= width+"px"
				box.style.height= width+"px"

			}

			input = document.getElementsByTagName("input");

			input[0].onclick = function () {
				if(input[0].value=="开始"){
					input[0].value = "停止";
					time = setInterval(run,10);
				}else{
					input[0].value = "开始";
					clearInterval(time);
				}
			}

			// 
		}
	</script>
</head>
<body>
	<input type="button" value="开始">
	<div id="box"></div>
</body>
</html>